/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cubelabs.nexus.service;

import cubelabs.nexus.dao.InstitueDao;
import cubelabs.nexus.entity.Institute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author chaitanya
 */
@Service
public class InstituteService {
	
	@Autowired
	private InstitueDao institueDao;
	
	
	public long createInstitute(Institute i ){
		institueDao.makePersistent(i);
		return i.getId();
	}

	public boolean editInstitute(Institute ins) {
		Institute i= institueDao.findById(ins.getId(), false);
		if(!ins.getUser().equals(i.getUser())) {
			return false;
		}
		institueDao.merge(ins);
		return true;
	}
	
	public Institute fetchInstitute(long insId) {
		return institueDao.findById(insId, false);
	}
}
